/**
 * 安卓白金英雄坛制作组 <br>
 * 文件名：YinYangJue.java <br>
 * 创建时间：2013-8-23 下午12:16:25 <br>
 * 所属项目：GmudEX <br>
 * @author 12548 <br>
 */
package lostland.gmud.exv2.battle.proc.stunt;

import com.orhanobut.logger.Logger;

import lostland.gmud.exv2.Gmud;
import lostland.gmud.exv2.battle.BattleScreen;
import lostland.gmud.exv2.battle.ViewScreen;
import lostland.gmud.exv2.battle.proc.DummyStatus;
import lostland.gmud.exv2.battle.proc.Status;
import lostland.gmud.exv2.battle.proc.StuntScreen;
import lostland.gmud.exv2.data.Npc;

/**
 * 类名：YinYangJue <br>
 * 说明：31.太极拳·2.阴阳诀
 *
 * @author 12548
 */
public class YinYangJue extends Status {


	/**
	 * @param zdp
	 * @param bdp
	 */
	public YinYangJue(Npc zdp, Npc bdp) {
		super(zdp, bdp);
	}


	boolean yin;
	int round = -1;

	/* （非 Javadoc）
	 * @see lostland.gmud.exv2.battle.proc.Status#execute()
	 */
	@Override
	public void execute() {

		if (round == -1) yin = Gmud.rand.nextBoolean();

		round++;

		if (yin) {
			if (round == 0) {
				new ViewScreen(BattleScreen.bsp(zdp, bdp, "$N招式一变翻为阴手，一股绵绵劲力直向$n全身罩去 ！")).pushToGame();
				pushToBattle();
				new DummyStatus().pushToBattle();
			} else {
				double hit_rate = 0.6 + 0.4 * (((double) zdp.getFp() - bdp.getFp()) / (double) (zdp.getFp() + bdp.getFp() + 1));

				Logger.i("命中率=" + hit_rate);

				boolean hit = Math.random() < hit_rate;
				if (hit) {
					new ViewScreen(BattleScreen.bsp(zdp, bdp, "$n於$N阴阳变化莫测之际，哪里还能招架，身子被太极柔劲推得跌跌撞撞！")).pushToGame();
					bdp.setTransfixed(bdp.getDz() + 8);
				} else {
					new ViewScreen(BattleScreen.bsp(zdp, bdp, "$n大吃一惊之际，急运内力全力相抗，狼狈万状地从太极柔劲中脱得身来！")).pushToGame();
					zdp.setTransfixed(zdp.getDz() + 3);
				}
				StuntScreen.StuntOver();
			}


		} else if (round == 0) {

			BattleScreen.getInstance().atkprocess(zdp, bdp, Gmud.zs.get(167 + round), this);
//			GmudWorld.bs.push(this);

//			AttackStatus.ag = GmudWorld.zs[121+round];
//			GmudWorld.bs.setStatus(new AnotherDummyStatus(new AttackStatus(this)));
//			GmudGame.getInstance().pushScreen(new ViewScreen(GmudGame.getInstance(), GmudWorld.bs.bsp(AttackStatus.ag.c));
//			GmudWorld.game.setScreen(new ViewScreen(GmudWorld.game));
		} else if (round < 3) {
			BattleScreen.getInstance().atkprocess(zdp, bdp, Gmud.zs.get(167 + round), this);
//			GmudWorld.bs.push(this);

//			AttackStatus.ag = GmudWorld.zs[121+round];
//			GmudWorld.bs.setStatus(new AttackStatus(this));
//			GmudGame.getInstance().pushScreen(new ViewScreen(GmudGame.getInstance(), GmudWorld.bs.bsp(AttackStatus.ag.c));
//			GmudWorld.game.setScreen(new ViewScreen(GmudWorld.game));
		} else {
			zdp.setTransfixed(zdp.getDz() + 3);
//			zdp.str_bouns += ( zdp.skills[1] +zdp.skills[31] * 2 ) / 10;

//			GmudWorld.bs.setStatus(new RoundOverStatus());
		}

	}

}
